package com.controller;

import com.domain.UserCollectionEntity;
import com.domain.Video;
import com.dto.JsonResponse;
import com.dto.PageResult;
import com.service.UserCollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 视频收藏记录表 前端控制器
 * </p>
 *
 * @author sly
 * @since 2024-01-13
 */
@RestController
@RequestMapping("/userCollection")
public class UserCollectionController {

    @Autowired
    private UserCollectionService userCollectionService;

    /**
     * 获取收藏的视频列表
     */
    @PostMapping("/pageListUserCollection")
    public JsonResponse<PageResult<Video>> pageListUserCollection(@RequestBody UserCollectionEntity userCollectionEntity) {
        PageResult<Video> pageResult = userCollectionService.pageListUserCollection(userCollectionEntity);
        return new JsonResponse<>(pageResult);
    }

    /**
     * 新增视频收藏
     */
    @PostMapping("/addUserCollection")
    public JsonResponse<String> addUserCollection(@RequestBody UserCollectionEntity userCollectionEntity) {
        userCollectionService.addUserCollection(userCollectionEntity);
        return JsonResponse.success();
    }

    /**
     * 删除视频收藏
     */
    @PostMapping("/deleteUserCollection")
    public JsonResponse<String> deleteUserCollection(@RequestBody UserCollectionEntity userCollectionEntity) {
        userCollectionService.deleteUserCollection(userCollectionEntity);
        return JsonResponse.success();
    }

}
